#include <iostream>
#include <unordered_map>
#include <iterator>
#define ll long long 

using namespace std;

int lowbit(int i){
	return i & -i;
}

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	
	int a[n];
	unordered_map<int,int> mp;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		++mp[a[i]];
	}
	
	
	ll ret = 0;
	
	for(auto it1 = mp.begin(); it1 != mp.end(); ++it1){
		int num;
		for(auto it2 = next(it1); it2 != mp.end(); ++it2){
			int sum = 0; 
			num = it1->first ^ it2->first;
			int cnt = 1;
			while(num){
				if(cnt & 1) sum += lowbit(num);
				num -= lowbit(num);
				++cnt;
			}
			ret += sum * it1->second * it2->second;
		}
	}
	/*	
	for(int i = 0; i < n; ++i){
		int num;
		int temp;
		for(int j = i+1; j < n; ++j){
			int sum = 0;
			num = a[i] ^ a[j];
			temp = num;
			if(summp.count(num)){
				sum = mp[num];
			}else{
				int cnt = 1;
				while(num){
					if(cnt & 1) sum += lowbit(num);
					num -= lowbit(num);
					++cnt;
				}
				summp[temp] = sum;
			}
			
			ret += sum;
		}
	}
	*/
	cout << ret;

	return 0;
}

